/**
 *
 * @author ace
 * @create 2017/8/22
 */
class LoginScene extends BaseScene {

    private img_logo: eui.Image;
    private lab_gongwang: eui.Label;
    private lab_wangyou: eui.Label;
    private lab_banhao: eui.Label;
    private lab_wangwen: eui.Label;
    private lab_icp: eui.Label;
    private btn_login: ButtonEx;
    private btn_agree: eui.CheckBox;
    private btn_protocol: eui.Image;

    constructor() {
        super();
        this.skinName = "LoginSceneSkin";
    }

    childrenCreated() {
        super.childrenCreated();

        this.img_logo.source = GameConfig.res_config['game_logo_login'];

        this.lab_gongwang.text = '' + GameConfig.copyright.gongwang;
        this.lab_wangyou.text = '' + GameConfig.copyright.wangyou;
        this.lab_banhao.text = '' + GameConfig.copyright.banhao;
        this.lab_wangwen.text = '' + GameConfig.copyright.wangwen;
        this.lab_icp.text = '' + GameConfig.copyright.icp;

        this.btn_login.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickHandler, this);
        this.btn_agree.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickHandler, this);
        this.btn_protocol.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickHandler, this);
    }

    private clickHandler(e: egret.TouchEvent) {
        switch (e.currentTarget) {
            case this.btn_login:
                GameStorage.setData(GameStorage.agreed, 1);

                gameManager.socketManager.connectToServer();
                break;
            case this.btn_agree:
                this.btn_login.enabled = this.btn_agree.selected;
                break;
            case this.btn_protocol:
                gameManager.open('ProtocolPanel');
                break;
        }
    }
}